from rest_framework.generics import ListAPIView
from rest_framework.permissions import DjangoModelPermissions, IsAdminUser

from apps.goods.models import GoodsCategory,GoodsChannelGroup,GoodsChannel
from rest_framework.viewsets import ModelViewSet
from apps.wthg_admin.serializers.channel import GoodsCategoryModelSerializer,GoodsChannelModelSerializer,GoodsChannelGroupModelSerializer
from apps.wthg_admin.utils import UtilsPageNumberPagination

class GoodsCategoryListAPIView(ListAPIView):
    """商品一级分类展示视图"""
    queryset = GoodsCategory.objects.filter(parent=None)
    serializer_class = GoodsCategoryModelSerializer


class GoodsChannelModelViewSet(ModelViewSet):
    """商品频道管理"""
    queryset = GoodsChannel.objects.all()
    serializer_class = GoodsChannelModelSerializer
    pagination_class = UtilsPageNumberPagination


class GoodsChannelGroupListAPIView(ListAPIView):
    """频道组展示视图"""

    queryset = GoodsChannelGroup.objects.all()
    serializer_class = GoodsChannelGroupModelSerializer

